package file.day9_18.day03;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;

public class OSWDemo {
    public static void main(String[] args) throws IOException {
        String line = "遗失的心跳";
        FileOutputStream fos = new FileOutputStream("fos.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);//说明要被转换的字符集类型

        osw.write(line);//先将数据存入缓冲区(内部的字节数组中)，当缓冲区满了时会自动写出一次
        osw.write("心跳呢，遗失了");

        System.out.println("写出完成");
        osw.close();
    }
}
